const http = require('http')
const urlModule  = require('url')
const fs = require('fs')
const path = require('path')

const server = http.createServer()



server.on('request', (req, res) => {
let url = req.url

let fullPath=path.join(__dirname, 'static',url)
//输入/？？？
if(url==='/'){
    fullPath=path.join(__dirname,'static','index.html')

}
fs.readFile(fullPath,(err,data)=>{
    if(err){
        return res.end('err.message')
    }
    return res.end(data)
})
})
server.listen(3000, () => {
    console.log('listen port 3000...')
})

